<?php
/**
 * The Loop in Main Page
 *
 * Section dedicated for rendering the number of posts in which we will expect
 * to return at least one or more posts.
 *
 */

$project = Padd_Theme_Option::get('project_cat_id', '1');
query_posts('cat=' . $project);
$cat = get_category($project);
?>

<div class="content-title">
	<h2><?php echo $cat->name; ?></h2>
</div>

<?php if (!have_posts()) : ?>

<p><?php echo __('There are no featured projects.', PADD_THEME_SLUG); ?></p></div>

<?php else : ?>

	<?php
		$thumbnail_type = PADD_THEME_SLUG . '-thumbnail';
		$padd_image_def = get_template_directory_uri() . '/images/thumbnail.png';
		$i = 1;
	?>
	<?php while (have_posts()) : ?>
		<?php the_post(); ?>
		<div id="entry-<?php the_ID(); ?>" <?php post_class('entry entry-' . $i); ?>>
			<div class="thumbnail">
				<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
					<?php
						if (has_post_thumbnail()) {
							the_post_thumbnail($thumbnail_type);
						} else {
							echo '<img class="image-thumbnail" alt="Default thumbnail." src="' . $padd_image_def . '" />';
						}
					?>
				</a>
			</div>
		</div>
		<?php $i = $i == 5 ? 1 : $i+1; ?>
	<?php endwhile; ?>
	<div class="clear"></div>
<?php endif;

wp_reset_query();
